<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>tql</title>

</head>

<body>
    <h1> Django模板语法学习 </h1>
    <!-- 通过在函数中传入的字典的键来获取其值 -->
    <div> {{ n1 }}</div>
    <div> {{ n2 }} </div>
    <hr />
    <h2> 列表 </h2>
    <!-- 获取列表中的值  -->
    <div> {{ n2.0 }} </div>
    <div> {{ n2.1 }} </div>
    <div> {{ n2.2 }} </div>
    <div> {{ n2.3 }} </div>
    <!--  通过循环获取列表中的值 -->
    <div>
        {% for item in n2 %}
        <span> {{ item }} </span>
        {% endfor %}
    </div>
    <hr />
    <h2> 字典 </h2>
    <div> {{ n3 }} </div>
    <!--  根据字典的键获取值  -->
    <div> {{ n3.伯 }} </div>
    <div> {{ n3.仲 }} </div>
    <div> {{ n3.叔 }} </div>
    <div> {{ n3.季 }} </div>
    <!--  遍历字典的键值对  -->
    <ul>
        {% for key,value in n3.items %}
        <li> {{key}} = {{value}}</li>
        {% endfor %}
    </ul>
    <hr />
    <h2> 条件语句 </h2>
    <!-- 条件判断 -->
    {% if n1 == '季' %}
    <h3>疾行</h3>
    {% elif n1 == '霁月' %}
    <h3>霁月</h3>
    {% else %}
    <h3>霁月壬</h3>
    <button type="button" class="btn btn-info">信息</button>
    {% endif %}
</body>

</html>